Move maintaining the focus chain
authorMatthias Clasen <mclasen@redhat.com>
Fri, 8 Mar 2019 18:52:46 +0000 (13:52 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 17 Mar 2019 01:24:45 +0000 (21:24 -0400)
Put this code in the same place where we generate
the crossing events.

gtk/gtkmain.c
gtk/gtkwindow.c

index e3c8b930cc6d80717453a36e80c8d27a2fe83f2b..92873dee1eb08de98dd97926b0e0d03f0bf46de5 100644 (file)
@@ -1458,6 +1458,21 @@ synth_crossing (GtkWidget       *widget,
 
   if (gdk_event_get_event_type (source) == GDK_FOCUS_CHANGE)
     {
+      /* maintain focus chain */
+      if (enter || notify_type == GDK_NOTIFY_INFERIOR)
+        {
+          GtkWidget *parent = gtk_widget_get_parent (widget);
+          if (parent)
+            gtk_widget_set_focus_child (parent, widget);
+        }
+      else if (!enter && notify_type != GDK_NOTIFY_INFERIOR)
+        {
+          GtkWidget *parent = gtk_widget_get_parent (widget);
+          if (parent)
+            gtk_widget_set_focus_child (parent, NULL);
+        }
+
+      /* maintain widget state */
       if (notify_type == GDK_NOTIFY_ANCESTOR ||
           notify_type == GDK_NOTIFY_INFERIOR ||
           notify_type == GDK_NOTIFY_NONLINEAR)
index 85a965c1696ea51fb4eb6bde8b7473fa440b597a..976777717d0151dfc0b817040a5a5ecc6def5ece 100644 (file)
@@ -7168,7 +7168,6 @@ gtk_window_set_focus (GtkWindow *window,
 {
   GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
   GtkWidget *old_focus = NULL;
-  GtkWidget *f;
   GdkSeat *seat;
   GdkDevice *device;
   GdkEvent *event;
@@ -7200,13 +7199,6 @@ gtk_window_set_focus (GtkWindow *window,
 
   g_clear_object (&old_focus);
 
-  for (f = focus; f; f = gtk_widget_get_parent (f))
-    {
-      GtkWidget *parent = gtk_widget_get_parent (f);
-      if (parent)
-        gtk_widget_set_focus_child (parent, f);
-    }
-
   g_object_notify (G_OBJECT (window), "focus-widget");
 }